<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>课程管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/left.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/vue.js"></script>
    <script>
        $(function () {
            var vue = new Vue({
                el:'#app',
                data:{
                    pages:1,
                    <!-- 调整分页数据,查询参数设置-->
                    param:{stuId:0,subId:0,page:1,rows:8,hour:0},
                    url:'http://localhost:8889',
                    periods:[],
                    students:[],
                    subjects:[],
                },
                methods:{
                    query:function () {
                        var that = this;
                        var ps = {
                            page:that.param.page,
                            rows:that.param.rows
                        }
                        if(that.param.stuId>0){
                            ps.stuId = that.param.stuId
                        }
                        if(that.param.subId>0){
                            ps.subId = that.param.subId
                        }
                        $.getJSON(that.url+'/student/queryPeriod',ps,function(data){
                            that.periods = data.list;
                            that.pages =  data.pages;
                        })
                    },
                    getSubjects:function(){
                        var that = this;
                        $.getJSON(that.url+"/Subject/query",function(data){
                            that.subjects = data;
                        })
                    },
                    getStudent:function(){
                        var that = this;
                        $.getJSON(that.url+"/student/findAll",function(data){
                            that.students = data;

                        })
                    },
                    setpage:function(page){
                        this.param.page = page;
                        this.query();
                    },
                    <!--重置函数-->
                    reset:function () {
                        this.param.subId = 0;
                        this.param.stuId = 0;
                        this.param.coaId = 0;
                        this.query();
                    },

                    order:function(classId){
                        var that = this;
                        $.get(that.url+'/class/findRes/'+classId,function(data){
                            console.log(data)
                            if(data){
                                location.href="reverse.html?classId="+classId;
                            }else{
                                alert("预约人数已满")
                                console.log(data)
                            }
                        })

                    }

                }
            })
            vue.query();
            vue.getStudent();
            vue.getSubjects();
            $("#header").load("header.html");
            $("#left").load("left.html");

        })

    </script>
    <style type="text/css" media="screen">
        .bg {
            background:url(images/subject/bg2.jpg) no-repeat center fixed;
            background-size:100%;
        }
        .bgcon{

            background: white;
            opacity:0.9;
        }
        .thead{
            border-bottom: #00FF00;
        }
        .tithead{
            margin-left:5px;
            margin-bottom: 30px;
        }
        .remark{
            margin-bottom: 20px;
            margin-right: 10px;
            color: #737373;
        }
    </style>
</head>
<body>
<div class="container-fluid bgcon" id="app">
    <div class="row" id="header">

    </div>
    <div class="row">
        <div class="col-md-2" id="left">

        </div>
        <div class="col-md-9" style="margin-left:30px;margin-top:10px">
            <div class="row tithead"><h3 class="glyphicon glyphicon glyphicon-bed"> 学员学习进度
            </h3></div>
            <div class="row" style="margin-top: 15px">
                <div class="col-md-2">
                    <select v-model="param.subId" class="form-control">
                        <option value="0">请选择科目</option>
                        <option v-for="s in subjects" :value="s.subId">{{s.subType}}</option>
                    </select>
                </div>
                <div class="col-md-2">
                    <select v-model="param.stuId" class="form-control">
                        <option value="0">请选择学员名称</option>
                        <option v-for="s in students" :value="s.stuId">{{s.stuName}}</option>
                    </select>
                </div>

                <div class="col-md-3">
                    <button @click="reset" class="btn btn-default" style="margin-right:10px">
                        <i class="glyphicon glyphicon-repeat"></i> 重置
                    </button>
                    <button @click="query" class="btn btn-primary">
                        <i class="glyphicon glyphicon-search"></i> 查询
                    </button>
                </div>
            </div>
            <div class="row" style="margin-top: 15px">
                <div class="col-md-12">
                    <div class="table-responsive">
                        <table id="tableList" class="table table-bordered table-hover">
                            <thead class="thead">
                            <tr>
                                <th class="text-center">序号</th>
                                <th class="text-center">学员姓名</th>
                                <th class="text-center">性别</th>
                                <th class="text-center">联系方式</th>
                                <th class="text-center">科目</th>
                                <th class="text-center">总学时</th>
                                <th class="text-center">已完成学时</th>
                                <th class="text-center">剩余学时</th>
                                <th class="text-center" colspan="3">操作</th>
                            </tr>
                            </thead>
                            <tbody v-for="(c,index) in periods">
                            <tr v-for="(cs,cindex) in c.subjectList" class="text-center">
                                <td>{{index+1}}</td>
                                <td>{{c.stuName}}</td>
                                <td v-if="c.stuSex === 1">男</td>
                                <td v-else-if="c.stuSex === 0">女</td>
                                <td>{{c.phone}}</td>
                                <td>{{cs.subType}}</td>
                                <td>{{cs.subTime}}</td>
                                <td>{{c.periodList[cindex].hour}}</td>
                                <td v-if="(cs.subTime-c.periodList[cindex].hour)>0">{{cs.subTime-c.periodList[cindex].hour}}</td>
                                <td v-else-if="(cs.subTime-c.periodList[cindex].hour)<=0">已完成</td>
                                <td>
                                    <button @click="" class="btn btn-sm btn-primary">联系学员</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12 text-center">
                    <nav aria-label="Page navigation">
                        <ul class="pagination" style="margin: 0">
                            <li @click="setpage(1)">
                                <a href="#" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li v-for="p in pages" @click="setpage(p)">
                                <a href="#">{{p}}</a>
                            </li>
                            <li @click="setpage(pages)">
                                <a href="#" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </ul>
                    </nav>
                </div>
            </div>
            <div class="row text-right remark"><h5>备注：学员进度模块. </h5></div>
        </div>
    </div>
</div>
</body>
</html>